package com.accounting.client.remote.enumeration;

import java.util.List;

import corelib.client.CollectionUtil;

public class TimeSpans {
	
	public final static int CurrentMonth = 0;
	public final static int CurrentYear  = 1;
	
	public final static TimeSpans CURRENT_MONTH = new TimeSpans(CurrentMonth, "当前月");
	public final static TimeSpans CURRENT_YEAR  = new TimeSpans(CurrentYear,  "当前年");
	
	public final static List<TimeSpans> All = CollectionUtil.newArrayList(CURRENT_MONTH, CURRENT_YEAR);
	
	private int type;
	private String name;
	
	public TimeSpans(int span, String name){
		this.type = span;
		this.name = name;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public static TimeSpans getByType(int span){
		for (TimeSpans timeSpan : All) {
			if (timeSpan.getType() == span){
				return timeSpan;
			}
		}
		return null;
	}
}
